package com.jcsz.gulimall.seckill.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @className: MyRedissonConfig
 * @author: 一把Po吉他
 * @date: 2022/11/1 21:05
 * @version: 1.0
 **/
@Configuration
public class MyRedissonConfig {

    @Bean(destroyMethod = "shutdown")
    public RedissonClient getRedissonClient(@Value("${spring.redis.host}") String url){
        Config config = new Config() ;
        //config.useSingleServer().setAddress("redis://192.168.2.137:6379").setPassword("123456");
        config.useSingleServer().setAddress("redis://"+url+":6379");
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }
}
